#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=100;
float a[maxn],b[maxn];
int mypartition(int l,int r,float base)
{
    int i=l-1,j=r+1;
    while(1)
    {
        while(a[++i]<base&&i<j);
        while(a[--j]>base);
        if(i>=j) break;
        swap(a[i],a[j]);
    }
    return j;
}
void print(int n)
{
    for(int i=1;i<=n;i++)
    cout<<a[i]<<" ";
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    cout<<mypartition(1,n,57)<<endl;
    print(n);cout<<endl;
    sort(a+1,a+1+n);
    print(n);
}